#ifndef USRAI_H
#define USRAI_H

#include "AI.h"

extern tagGame tagUsrGame;
extern ins UsrIns;
/*##########DO NOT MODIFY THE CODE ABOVE##########*/

class UsrAI:public AI
{
public:
    UsrAI(){this->id=0;}
    ~UsrAI(){}
    void DetermineHomeCorner();
    void ExploreOcean();
    void HandleEnemyShips();
    pair<int, int> GetOppositeCorner();
    int find_block(int &x,int &y);
    int find_2h_block(int &x,int &y);
    int find_3x3_block(int &x, int &y);
    int find_non_block(int &x, int &y);
    int find_mar_block(int &x, int &y);
    int findResource(tagFarmer farmer,int type);
    void House_build(int HOME_MAX);
    void House_build2(int HOME_MAX);
    void Dock_build();
    void Market_build(int makCount);
    void Granary_build(int guMAX);
    void produce_farmer(int humanCount);
    void produce_farmer2(int humanCount);
    void produce_sailing(int maxCount);
    void duggingtask(int maxCount);
    void Cuttingtask(int maxCount);
    void Fishingtask(int maxCount);
    void Huntingtask(int maxCount);
    void boatfishing();
    void processFisherman();
    void produce_boat(int boatCount);
    void produce_ship(int maxCount);   
    void farm_build(int maxCount);
    void Upgradewood();
    void Upgradefood();
    void Upgradestone();
    void farmerManage ();
    void initMap();
    void mark_Resources();
    void mark_Buildings();
    void mark_Units();
private:
    void processData() override;
    tagInfo getInfo(){return tagUsrGame.getInfo();}
    int AddToIns(instruction ins) override
    {
        UsrIns.lock.lock();
        ins.id=UsrIns.g_id;
        UsrIns.g_id++;
        UsrIns.instructions.push(ins);
        UsrIns.lock.unlock();
        return ins.id;
    }
    void clearInsRet() override
    {
        tagUsrGame.clearInsRet();
    }
    /*##########DO NOT MODIFY THE CODE IN THE CLASS##########*/
    bool tryBuildBuilding(int buildingType, int requiredWood, int maxCount, int reqiredBuilding,int is_settler=0);
    //
};

/*##########YOUR CODE BEGINS HERE##########*/

/*##########YOUR CODE ENDS HERE##########*/
#endif // USRAI_H
